<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/7
 * Time: 18:37
 */

namespace app\web\controller;
use app\common\controller\HomeBase;
use app\common\model\Regist as RegistModel;
use think\Config;

class Regist extends HomeBase
{
    private $_regist_model;
    protected function _initialize(){
        $this->_regist_model = new RegistModel();
    }
    public function index(){
//        $Group = new UserModel();
//        $GroupArr = $Group->field('username,id')->where('fid = 2')->select();
//        $this->assign('GroupArr',$GroupArr);
//        $this->assign('title',
//            [
//                'title'=>'注册'
//            ]);
        return $this->fetch();
    }

    public function save(){
        $userMsg = $this->request->param();
        unset($userMsg['confirm_password']);
        $userMsg['password'] = md5($userMsg['password'] . Config::get('salt'));
        $result = $this->_regist_model->save($userMsg);
        if($result){
            $this->success('注册成功',url('web/login/index'));
        }else{
            $this->error('注册失败',url('web/regist/index'));
        }


    }
}




















